﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IService.DataDLL.Utility
{
    public class HtmlDecode
    {
        public static string HtmlDiscode(string theString)
        {
            theString = theString.Replace("&gt;", ">");
            theString = theString.Replace("&lt;", "<");
            theString = theString.Replace("&nbsp;", " ");
            theString = theString.Replace(" &nbsp;", "  ");
            theString = theString.Replace("&quot;", "\"");
            theString = theString.Replace("&#39;", "\'");
            theString = theString.Replace("<br/> ", "\n");
            return theString;
        }

        public static string HtmlEncode(string theString)
        {
            theString = theString.Replace(">", "&gt;");
            theString = theString.Replace("<", "&lt;");
            theString = theString.Replace(" ", "&nbsp;");
            theString = theString.Replace("\"", "&quot;");
            theString = theString.Replace("\'", "&#39;");
            theString = theString.Replace("\n", "<br/>");
            return theString;
        }

        public static string HtmlDeleteCode(string theString)
        {
            theString = theString.Replace(" ", "");
            theString = theString.Replace("&nbsp;", "");
            theString = theString.Replace("\n", "");
            theString = theString.Replace("\r", "");
            return System.Text.RegularExpressions.Regex.Replace(theString, "<[^>]*>", "");
        }
    }
}
